<?php
/*
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 * $Id: 2017-12-13 03:39:35 apple $
*/
/*
	签到记录
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'list';
$return=array();
if($_RQ['op']=='list'){
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$params=array('uniacid'=>$_SESSION['uniacid']);
	$return['params']=array();	
	//门店ID
	if(!empty($_RQ['id'])){
		$params['store_id']=intval($_RQ['id']);
		$return['params']['id']=$_RQ['id'];
	}
	//会员ID
	if(!empty($_RQ['mid'])){
		$params['mid']=intval($_RQ['mid']);
		$return['params']['mid']=$_RQ['mid'];
	}
	if(!empty($_RQ['uname'])){
		$params['uname like']='%'.trim($_RQ['uname']).'%';
		$return['params']['uname']=$_RQ['uname'];
	}
	if(!empty($_RQ['createtime'])){
		$params['createtime like']='%'.trim($_RQ['createtime']).'%';
		$return['params']['createtime']=$_RQ['createtime'];
	}
	$orderby='id desc';
	$list=pdo_getslice('jy_yiliao_qdlinelog',$params,array($pindex,$psize),$total,'','',$orderby);
	if($list){
		foreach($list as &$log){
			$log['member']=cfc('core')->member_show($log['mid']);
		}
	}
	$return['list']=$list?$list:array();
	$totalpage=ceil($total/$psize);
	$totalpage=intval($totalpage);
	$return['totalpage'] =$totalpage;
	$return['params']['page'] =$pindex;
	$htmls=array(
		'type'=>'list',
		'export'=>'export',
		'tabs'=>array(
			array('op'=>'list','title'=>'客户签到记录'),
		),
		'list'=>array('data'=>'list','edit'=>false,'list'=>array(
			array('name'=>'mid','title'=>'会员ID','type'=>'string'),
			array('name'=>'member','title'=>'粉丝信息','type'=>'member'),
			array('name'=>'uname','title'=>'姓名','type'=>'string'),
			array('name'=>'uphone','title'=>'电话','type'=>'string'),
			array('name'=>'createtime','title'=>'签到日期','type'=>'string'),
		)),
		'search'=>array(
			array('name'=>'uname','width'=>10,'title'=>'姓名','type'=>'string'),
			array('name'=>'createtime','width'=>10,'title'=>'签到日期','type'=>'string'),
		)
	);
	$return['htmls']=$htmls;
	exi($return);
}
if($_RQ['op']=='export'){
	$params=array('uniacid'=>$_SESSION['uniacid']);
	if(!empty($_RQ['id'])){
		$params['store_id']=intval($_RQ['id']);
		$return['params']['id']=$_RQ['id'];
	}
	//会员ID
	if(!empty($_RQ['mid'])){
		$params['mid']=intval($_RQ['mid']);
		$return['params']['mid']=$_RQ['mid'];
	}
	if(!empty($_RQ['createtime'])){
		$params['createtime like']='%'.trim($_RQ['createtime']).'%';
		$return['params']['createtime']=$_RQ['createtime'];
	}
	$log=pdo_getall('jy_yiliao_qdlinelog',$params);
	foreach($log as &$v){
		$v['member']=cfc('core')->member_show($v['mid']);
		$v['nickname']=$v['member']['nickname'];
	}
	$header=array(
		'mid'=>'会员ID',
		'nickname'=>'粉丝信息',
		'uname'=>'姓名',
		'uphone'=>'电话',
		'createtime'=>'签到日期',
	);
	cfc('tools')->export2excel($header,$log,'签到表');
}